﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using SpectrumAnalyser.Controls.Wpf.Helpers;

namespace SpectrumAnalyser.CustomControls.Wpf.BusyIndicator
{
    /// <summary>
    /// Interaction logic for BusyIndicator.xaml
    /// </summary>
    public partial class BusyIndicator : UserControl
    {
        public BusyIndicator()
        {
            InitializeComponent();
            this.DataContext = this;
        }

        /*public static readonly DependencyProperty IsActiveProperty =
            DependencyProperty.Register("IsActive", typeof (bool), typeof (BusyIndicator), new PropertyMetadata(default(bool)));
*/
        public bool IsActive
        {
            get { return _isBusy; }
            set
            {
                _isBusy = value;
                BusyRoot.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
                UIHelper.ForceUIToUpdate();
            }
        }

        private bool _isBusy;

        public new static readonly DependencyProperty BackgroundProperty =
            DependencyProperty.Register("Background", typeof (Brush), typeof (BusyIndicator), new PropertyMetadata(default(Brush)));

        public new Brush Background
        {
            get { return (Brush) GetValue(BackgroundProperty); }
            set { SetValue(BackgroundProperty, value); }
        }
    }
}
